Ext.regModel('Employee', {
	fields : [ {
		name : 'employeeId',
		type : 'string'
	}, {
		name : 'firstName',
		type : 'string'
	}, {
		name : 'lastName',
		type : 'string'
	}, {
		name : 'eMail',
		type : 'string'
	}, {
		name : 'phoneNumber',
		type : 'string'
	}, {
		name : 'hireDate',
		type : 'string'
	}, {
		name : 'jobId',
		type : 'string'
	}, {
		name : 'salary',
		type : 'string'
	}, {
		name : 'commission',
		type : 'string'
	}, {
		name : 'managerId',
		type : 'string'
	}, {
		name : 'departmentId',
		type : 'string'
	} 
	]
});

var empStoreListener = {
	add : function() {
		console.log("add");
	},
	beforeload : function() {
		console.log("beforeload");
	},
	datachanged : function() {
		console.log("datachanged");
	},
	exception : function() {
		console.log("exception");
	},
	load : function() {
		console.log("load");
	},
	remove : function() {
		console.log("remove___");
	},
	update : function() {
		console.log("loadexception");
	}
}

//4. 데이터 접근.
function loadData()
{
 // 데이터 읽기.
	var record              = empStore.getAt(0);   
	console.log(record);   
	console.log(record.data.id);
	console.log(record.data.firstName);
	console.log(record.data["lastName"]);
}

var empStoreListener = {
	add : function() {
		console.log("add");
	},
	beforeload : function() {
		console.log("beforeload");
	},
	datachanged : function() {
		console.log("datachanged");
	},
	exception : function() {
		console.log("exception");
	},
	load : function() {
		console.log("load");
	},
	remove : function() {
		console.log("remove___");
	},
	update : function() {
		console.log("loadexception");
	}
}

var employeeProxy = new Ext.data.AjaxProxy({
//	url: 'http://192.168.0.74:8080/simple-webapp/json', 안된다.... 이유는 모르겠다
	url: '../searchJsonEmployee.do',
	type:'ajax',
	model: 'Employee',
	reader:{
		type:'json',
		root:'result'
	}
});
//3. Store생성.
var empStore = new Ext.data.JsonStore({
	model : 'Employee',
	encode: 'true',
	proxy: employeeProxy
});
empStore.load();

var employee_list = new Ext.List( {
	fullscreen : true,
	store : empStore, 
	listeners: {
        itemtap: function(dv, ix, item, e) {
            //alert(this.store.getAt(ix).data.employeeId);
        }
    },
	itemTpl : '<div class="employee_service"><strong>employee id</strong> : {employeeId}<br/>' +
	'<strong>name</strong> : {firstName}  {lastName} <br/>' +
	'<strong>mail</strong> : {eMail}' +
	'<br/><strong>phone</strong> : {phoneNumber}' +
	'<br/><strong>hire date</strong> : {hireDate}' +
	'<br/><strong>job id</strong> : {jobId}' +
	'<br/><strong>salary</strong> : {salary}' +
	'<br/><strong>commisstion</strong> : {commission}' +
	'<br/><strong>manager id</strong> : {managerId}' +
	'<br/><strong>department id</strong> : {departmentId} </div>'
} );
